<template>
  <div class="c-pb84 copyNot">
    <div v-if="testRes!=null">
      <h2 class="c-fs36 c-fc-myellow c-textAlign-c c-mt28 c-fw-n" v-if="testRes.scoringMethod!=4">测试结果</h2>
      <div class="c-mt40">
        <div v-if="testRes.scoringMethod!=4" class="c-ww250 c-hh250 c-brp50 c-center c-textAlign-c c-text-hidden c-point-bd c-p">
          <template v-if="testRes && testRes.isCheck != -1">
            <div class="c-pa accuracy-wrap c-p-l0 c-p-t0 c-pz99">
              <div class="c-fs24 c-fc-xblack c-pt30">正确率</div>
              <div class="c-fs40 rate-color c-mt28">{{Number(testRes.accuracy*100).toFixed(0)+'%'}}</div>
            </div>
            <div :style="{top: testRes.accuracy<0.9 ? testRes.accuracy<0.1 ? testRes.accuracy==0 ? (5.85-0*6.45)+'rem' : (5.85-0.1*6.45)+'rem' : (5.85-testRes.accuracy*6.45)+'rem' : testRes.accuracy == 1 ? (5.85-1*6.45)+'rem' : (5.85-0.9*6.45)+'rem'}" class="c-www500 wave-img c-flex-row c-p">
              <img class="show c-www500 c-hh260" src="../../../../assets/i/wap/exam/bolang.png" />
            </div>
          </template>
        </div>
        <div class="c-textAlign-c c-mt16"><span class="c-fs22 c-fc-gray">共{{testRes.allNum}}题目</span><span class="c-fs22 c-fc-gray c-ml20">答对{{testRes.rightNum}}题</span></div>
        <div class="c-w50 c-m-0auto c-fs28 c-fc-white c-hh80 c-textAlign-c c-flex-row c-flex-center theme-bg c-mt80 c-br10 c-mb30" @click="goAnalysis">查看解析</div>
        <div class="c-w50 c-m-0auto c-fs28 c-fc-white c-hh80 c-textAlign-c c-flex-row c-flex-center theme-bg c-br10 c-mb30" @click="testAgain">继续练习</div>
        <div class="c-w50 c-m-0auto c-fs28 c-fc-white c-hh80 c-textAlign-c c-flex-row c-flex-center theme-bg c-br10 c-mb30" @click="goExit">退出练习</div>
      </div>
    </div>
  </div>
</template>

<script>
import { utilJs } from "@/utils/common.js"
export default {
  name: "ExaminationWrongResult",
  components: {
  },
  props: [],
  data() {
    return {
      theme: localStorage.getItem("colorName") ? localStorage.getItem("colorName") : "mb5_default",
      review: '',
      testRes: null,
      paperMainId: -1,
      topicId: -1,
      showCer: false,
      isDrawing: false,
      examinationInfo: null,
      isResurvey: false, //支持重测，重测时间是否已到
      examMainId: 0,
      paperId:''
    };
  },
  created() {
    utilJs.appShare(this);
  },
  activated() {
    setDocumentTitle("测评结果");// eslint-disable-line
    this.topicId = this.$route.query.topicId;
    this.paperMainId = this.$route.query.paperMainId;
    this.examMainId = this.$route.query.examMainId;
    this.paperId = this.$route.query.paperId || '';
    this.testRes = null;
    this.examinationInfo = null;
    let $this = this;
    //获取测试结果数据
    utilJs.getMethod(global.apiurl + 'exam/completeCollectionShow/' + this.examMainId, function (res) {
      $this.testRes = res;
      // let nt = (new Date()).getTime();
      // let lt = utilJs.getTimeByDate($this.testRes.lastJoinTime);
      // if (($this.testRes.intervalTime != 0) && (lt + $this.testRes.intervalTime * 60 * 60 * 1000 > nt)) {
      //   $this.isResurvey = false;
      // } else {
      //   $this.isResurvey = true;
      // }
      // if ($this.testRes.isRemark != -1) {
      //   $this.review = $this.testRes.remark;
      // } else {
      //   $this.review = '';
      // }
    });
  },
  deactivated() {

  },
  mounted() { },
  computed: {},
  watch: {},
  methods: {
    goExit() {
      this.$router.go(-1);
    },
    goAnalysis: function (eId) {
      this.$routerGo(this, "push", {
        path: "/member/myWrongTopic/examWrongTopic/examinationWrongAnswerAnalyze",
        query: { examMainId: this.examMainId, paperId:this.paperId}
      });
    },
    testAgain() {
      let $this = this;
      utilJs.postMethod(global.apiurl + "exam/joinCollectionExam", {
          ckFrom: this.topicId ? 1 : 2,
          prodId: this.topicId ? this.topicId : this.paperId
        },
        res => {
          $this.$routerGo($this, "replace", {
            path: "/member/myWrongTopic/examWrongTopic/examinationWrongAnswer",
            query: { questionNum: $this.testRes.allNum, examMainId: res.examMainId, goOnNum: 1, topicId: $this.topicId, paperId:$this.paperId }
          });
        })
    },
    goTest: function (eId) {
      //    this.$emit("testAgain",eId);
      let nt = (new Date()).getTime();
      let lt = utilJs.getTimeByDate(this.testRes.lastJoinTime);
      if ((this.testRes.intervalTime != 0) && (lt + this.testRes.intervalTime * 60 * 60 * 1000 > nt)) {
        let interval = lt + (this.testRes.intervalTime * 60 * 60 * 1000) - nt;
        let secondTime = parseInt(interval / 1000);
        let minuteTime = 0;
        let hourTime = 0;
        if (secondTime > 60) {
          minuteTime = parseInt(secondTime / 60);
          secondTime = parseInt(secondTime % 60);
          if (minuteTime > 60) {
            hourTime = parseInt(minuteTime / 60);
            minuteTime = parseInt(minuteTime % 60);
          }
        }
        let showTime = minuteTime > 0 ? (hourTime > 0 ? (hourTime + '时' + minuteTime + '分' + secondTime + '秒') : (minuteTime + '分' + secondTime + '秒')) : (secondTime + '秒')
        this.$showCjToast({
          text: '请在' + showTime + '后重测',
          type: "text",
        });
      } else {
        let $this = this;
        utilJs.postMethod(global.apiurl + "paperLibrary/createExam", {
          paperMainId: this.paperMainId,
          topicId:this.topicId
        }, res => {
          $this.$routerGo($this, "replace", {
            path: "/homePage/examination/examinationAnswer",
            query: { paperMainId: $this.paperMainId, topicId: $this.topicId, goOnNum: 1, paperId:$this.paperId }
          });
        })
      }
    },
    //分享
    wechatShare: function () {
      utilJs.wechatConfig("", "", "", "", function () { });
    },
    //手机端分享
    appShare: function () {
      utilJs.appShareTrue("", "", "", "");
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style scoped>
.btn-wrap {
  width: 100%;
  max-width: 640px;
  border-top: 1px solid #ddd;
  background: #fff;
  position: fixed;
  bottom: 0;
  z-index: 11;
}
.btn-next-question {
  font-size: 0.7rem;
  height: 2.1rem;
}
.c-hh250 {
  height: 6.25rem;
}
.c-point-bd {
  border: 0.22rem solid #d6ecfa;
}
.accuracy-wrap {
  width: 5.8rem;
  height: 5.8rem;
}
.c-pb84 {
  padding-bottom: 2.1rem;
}
.c-www500 {
  width: 12.5rem;
}
.rate-color {
  color: #0f72a1;
}
@keyframes waveMove {
  from {
    left: 0;
  }
  to {
    left: -6.25rem;
  }
}
@-moz-keyframes waveMove /* Firefox */ {
  from {
    left: 0;
  }
  to {
    left: -6.25rem;
  }
}
@-webkit-keyframes waveMove /* Safari 和 Chrome */ {
  from {
    left: 0;
  }
  to {
    left: -6.25rem;
  }
}
@-o-keyframes waveMove /* Opera */ {
  from {
    left: 0;
  }
  to {
    left: -6.25rem;
  }
}

.wave-img {
  animation: waveMove 6s linear infinite;
  /* Firefox: */
  -moz-animation: waveMove 6s linear infinite;
  /* Safari 和 Chrome: */
  -webkit-animation: waveMove 6s linear infinite;
  /* Opera: */
  -o-animation: waveMove 6s linear infinite;
}
.c-ww480 {
  width: 12rem;
}
.c-bg-draw {
  background-color: #fa875d;
}
.block-center {
  margin-left: auto;
  margin-right: auto;
}
.c-ph72 {
  padding-left: 1.8rem;
  padding-right: 1.8rem;
}
.c-lh64 {
  line-height: 1.6rem;
}
.wrong-answer {
  color: #F26363;
}
.right-answer {
  color: #6EC589;
}
.c-mb32 {
  margin-bottom: 0.8rem;
}
</style>